<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/commons/taglibs.jsp"%>
<form id="inputForm2" class="well form-inline" action="${ctx}/adoms/orderLine/update" method="post">
	<input type="hidden" name="id" value="${orderLine.id}" />
	<input id="marchandise.id" name="marchandise.id" type="hidden" value="${orderLine.marchandise.id}" size="30" maxlength="80" />
	<input id="order.id" name="order.id" type="hidden" value="${orderLine.order.id}" />
	<input id="hasIn" name="hasIn" type="hidden" value="${orderLine.hasIn}" />
	<input id="hasleft" name="hasleft" type="hidden" value="${orderLine.hasleft}" />
	<input id="flag" name="flag" type="hidden" value="myEdit" />
	<table class="table table-striped table-bordered table-condensed">
		<tr>
			<td class="span2">订单编号:</td>
			<td>
				<span class="tBlue">${orderLine.order.code}</span>
			</td>
		</tr>
		<tr>
			<td>商品名称:</td>
			<td>
				<span class="tBlue">${orderLine.marchandise.name}</span>
			</td>
		</tr>
		<tr>
			<td>商品规格:</td>
			<td>
				<span class="tBlue">${orderLine.marchandise.spcification}</span>
				<span id="numOfBox" class="hide">${orderLine.marchandise.numOfBox }</span>
			</td>
		</tr>
		<tr>
			<td>单价:</td>
			<td>
				<span class="tBlue">
					￥
					<span id="mPrice" class="tRed">${orderLine.marchandise.price}</span>
					元
				</span>
			</td>
		</tr>
		<tr>
			<td>订购数量:</td>
			<td>
				<input id="items" class="span2" name="items" type="text" value="${orderLine.items}" size="30" maxlength="8" />
				(${orderLine.marchandise.packageing })
				<span class="tBlue">或</span>
				<input id="boxNum" class="span2" name="boxNum" type="text" value="${orderLine.boxNum}" size="30" maxlength="8" />
				(件)
			</td>
		</tr>
		<tr>
			<td>总价:</td>
			<td>
				<input id="totalPrice" name="totalPrice" class="span2" readonly="readonly" type="text" value="${orderLine.totalPrice}" size="30" maxlength="15" />
				(元)
			</td>
		</tr>
		<tr height="50">
			<td colspan="2" align="center">
				<input class="btn btn-primary span1" type="submit" value="提 交" />
				&nbsp;
				<input class="btn span1 btn-info" type="button" value="返 回" back="back" />
			</td>
		</tr>
	</table>
</form>
<script>
	$(document).ready(function() {
		//为inputForm注册validate函数
		$("#inputForm2").validate({
			rules : {
				boxNum : "required",
				items : {
					required : true,
					number : true,
					min : 1
				}
			}
		});
		//计算总价//numOfBox//mPrice
		$("#boxNum").keyup(function() {
			var numOfBox = parseInt($("#numOfBox").html());
			var boxNum = $(this).val();
			var items = (boxNum * numOfBox).toFixed(0);
			$("#items").val(items);
			var price = parseFloat($("#mPrice").html());
			$("#totalPrice").val((items * price).toFixed(2));
		});
		$("#items").keyup(function() {
			var numOfBox = parseInt($("#numOfBox").html());
			var items = $(this).val();
			var boxNum = (items / numOfBox).toFixed(2);
			$("#boxNum").val(boxNum);
			var price = parseFloat($("#mPrice").html());
			$("#totalPrice").val((items * price).toFixed(2));
		});
	});
</script>